<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:PlanetWPF.Toolbelt.Controls"
    >
  <DataTemplate x:Key="GridHeaderRowTemplate">
    <local:PowerGridHeaderCell
      CellColumn="{Binding}"
      CellType="ColumnHeader" 
      ParentRow="{Binding RelativeSource={RelativeSource FindAncestor, 
					AncestorType={x:Type local:PowerGridColumnHeaderRow}}}"
          />
  </DataTemplate>

  <Style x:Key="HeaderRowScroller"
           TargetType="{x:Type ItemsControl}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ItemsControl}">
          <VirtualizingStackPanel Orientation="Horizontal"
                      IsItemsHost="True" />
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style TargetType="{x:Type local:PowerGridColumnHeaderRow}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type local:PowerGridColumnHeaderRow}">
          <ItemsControl Name="PART_ItemsControl"
                        Margin="0,0,0,0" 
                        Style="{StaticResource HeaderRowScroller}" 
                        ItemTemplate="{StaticResource GridHeaderRowTemplate}"
                        ItemsSource="{TemplateBinding Columns}">
          </ItemsControl>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

</ResourceDictionary>